<!DOCTYPE html >
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<title>大棚后台登录</title>
<link href="css/bootstrap.min.css" title="" rel="stylesheet" />
<link title="orange" href="css/login.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="../layui2.2.6/css/layui.css" media="all" />
</head>

<body>
<div style="height:1px;"></div>
<div class="login">
 <header>
    <h1>欢迎登陆</h1>
 </header>
 <div class="sr">
    <form>
	    <div class="name">
			<label>
			<i class="sublist-icon glyphicon glyphicon-user"></i>
			</label>
			<input type="text"  id="userName"  placeholder="这里输入登录名" class="name_inp">
		</div>
		 <div class="name">
			<label>
			<i class="sublist-icon glyphicon glyphicon-pencil"></i>
			</label>
			<input type="password" id="code" placeholder="这里输入登录密码" class="name_inp">
		</div>
		<button class="dl" id='btn'>立即登陆</button>
	</form>
 </div>
</div>
<script type="text/javascript" src="../js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../layui2.2.6/layui.all.js"></script>
</body>
<script type="text/javascript">
	$(function(){
		$("#btn").click(function(){
			var userName = $("#userName").val();
			var code = $("#code").val();
			debugger;
			if(userName.length <= 0 ){
				alert("请输入用户名");
			}else if(code.length <= 0 ){
				alert("请输入密码");
			}else{
				var data = {
					"userName" : userName,
					"userCode" : code
				}
				$.post("../../admin/adminLogin",data,function(data){
					if(data.code == 100){
						var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
						 setTimeout(function(){
					            top.layer.close(index);
								top.layer.msg("添加成功"); 
					 			layer.closeAll("iframe");
						 		//刷新父页面
						 		location.href = "../index.html";
					        },2000);
					}else{
						layer.msg('用户名或者密码错误', {icon: 5});
						return;
					}
				})
			}
			return false;
		})
	})
</script>
</html>